package com.ruoyi.project.cms.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.cms.domain.BizPhoneNum;
import com.ruoyi.project.cms.service.IBizPhoneNumService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 手机归属地Controller
 * 
 * @author ruoyi
 * @date 2024-03-30
 */
@RestController
@RequestMapping("/cms/num")
public class BizPhoneNumController extends BaseController
{
    @Autowired
    private IBizPhoneNumService bizPhoneNumService;

    /**
     * 查询手机归属地列表
     */
    @PreAuthorize("@ss.hasPermi('cms:num:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizPhoneNum bizPhoneNum)
    {
        startPage();
        List<BizPhoneNum> list = bizPhoneNumService.selectBizPhoneNumList(bizPhoneNum);
        return getDataTable(list);
    }

    /**
     * 导出手机归属地列表
     */
    @PreAuthorize("@ss.hasPermi('cms:num:export')")
    @Log(title = "手机归属地", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizPhoneNum bizPhoneNum)
    {
        List<BizPhoneNum> list = bizPhoneNumService.selectBizPhoneNumList(bizPhoneNum);
        ExcelUtil<BizPhoneNum> util = new ExcelUtil<BizPhoneNum>(BizPhoneNum.class);
        util.exportExcel(response, list, "手机归属地数据");
    }

    /**
     * 获取手机归属地详细信息
     */
    @PreAuthorize("@ss.hasPermi('cms:num:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(bizPhoneNumService.selectBizPhoneNumById(id));
    }

    /**
     * 新增手机归属地
     */
    @PreAuthorize("@ss.hasPermi('cms:num:add')")
    @Log(title = "手机归属地", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizPhoneNum bizPhoneNum)
    {
        return toAjax(bizPhoneNumService.insertBizPhoneNum(bizPhoneNum));
    }

    /**
     * 修改手机归属地
     */
    @PreAuthorize("@ss.hasPermi('cms:num:edit')")
    @Log(title = "手机归属地", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizPhoneNum bizPhoneNum)
    {
        return toAjax(bizPhoneNumService.updateBizPhoneNum(bizPhoneNum));
    }

    /**
     * 删除手机归属地
     */
    @PreAuthorize("@ss.hasPermi('cms:num:remove')")
    @Log(title = "手机归属地", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bizPhoneNumService.deleteBizPhoneNumByIds(ids));
    }
}
